#ifndef _GAME_LOG_MANAGER_H_
#define _GAME_LOG_MANAGER_H_

#include "Thread.h"
#include <deque>
#include <string>

class CGameLogManager : public SGLib::IRunnable
{
public:
    enum
    {
        E_LogCount_Limit = 1000,
        E_LogTime_Limit = 600, // 5min
    };

    CGameLogManager();
    virtual ~CGameLogManager();
    bool Start();
    void Stop();
    virtual void Run();
    void Check2Log();
    void AddGameLog(u64 userid, s32 gameid, u64 serverid, s32 roomid, u64 battleid, s64 winmoney, s32 tax, s8 isoffline, s8 isrobot, u64 tbegin, u64 tend, std::string &channel, s32 reserve1=0, s32 reserve2=0, const char *reserve3="");
    s32 QueLength();

private:
    struct _logData
    {
        u64 userid;
        s32 gameid;
        u64 serverid;
        s32 roomid;
        u64 battleid;
        s64 winmoney;
        s32 tax;
        s8 isoffline;
        s8 isrobot;
        u64 tbegin;
        u64 tend;
        std::string channel;
        s32 reserve1;
        s32 reserve2;
        std::string reserve3;
    };
    void _DoLog(std::deque<_logData> &logQue);

    SGLib::CEvent m_workSignal;
    SGLib::CThread *m_worker;
    bool m_isStop;
    std::string m_curMonth;
    u64 m_lastLogTime;

    SGLib::CLock m_lock;
    std::deque<_logData> m_logQue;
};


#endif

